﻿using System;

namespace Modbus.Messages
{
	internal class ModbusMessage : IModbusMessage
	{
		private byte functionCode;

		public virtual void Read(ModbusReader reader)
		{
			if (reader == null)
			{
				throw new ArgumentNullException("reader");
			}

			this.functionCode = reader.ReadByte();
		}

		public virtual void Write(ModbusWriter writer)
		{
			if (writer == null)
			{
				throw new ArgumentNullException("writer");
			}

			writer.Write(this.functionCode);
		}

		public byte FunctionCode
		{
			get { return this.functionCode; }
			set { this.functionCode = value; }
		}
	}
}
